{% extends "sphene/sphboard/base.html" %}

{% load sphboard_extras %}

{% block content %}

  <a href="../../latest/{{ category_id }}/">Latest</a> | {% sphboard_displayBreadcrumbsForCategory category %}<br/><br/>

  {% if user.is_authenticated %}
    {% if category %}
      {% if category.has_monitor %}
        {% if category.has_direct_monitor %}
          You are currently receiving email notifications on new posts. - <a href="../../togglemonitor_category/{{ category_id }}/">Stop notifications</a>
        {% else %}
          You are currently receiving email notifications on new posts because you subscribed to a parent category.
        {% endif %}
      {% else %}
        <a href="../../togglemonitor_category/{{ category_id }}/">Notify me by email on new posts.</a>
      {% endif %}
    {% else %}
      {% if group.has_monitor %}
        You are currently receiving email notifications on new posts. - <a href="../../togglemonitor_group/{{ group.id }}/">Stop notifications</a>
      {% else %}
        {% if rootCategories %}
          <a href="../../togglemonitor_group/{{ group.id }}/">Notify me by email on new posts.</a>
        {% endif %}
      {% endif %}
    {% endif %}
    <br/><br/>
  {% endif %}

  {% if rootCategories %}
  <table class="sphboard_categories">
    <tr>
      <th colspan='6'>Title</th>
      <th>Threads</th>
      <th>Posts</th>
      <th>Last Post</th>
    </tr>
    {% sphboard_displayCategories rootCategories 5 %}
  </table>
  <br/><br/>
  {% else %}
    {% if not category %}
      There are currently no categories. (Or you have no permission to see them.)
    {% endif %}
  {% endif %}

  {% if isShowLatest or category.canContainPosts %}
    {% include "sphene/sphboard/_new_thread_link.html" %}
    <table class="sphboard_thread_list">
      <tr>
        <th class="sphboard_mainhead" colspan="4">Threads</th>
      </tr>
      <tr>
        <th colspan="2">Subject / Author</th>
        <th>Posts</th>
        <th>Last Post</th>
      </tr>
      {% for thread in thread_list %}
        <tr>
          <td width="20px"><img src="/static/sphene/sphboard/icons/{% if thread.has_new_posts %}new{% endif %}folder.gif" width='16px' height='16px' /></td>
          <td>{% if thread.is_sticky %}<b>Sticky:</b> {% endif %}{% if thread.is_poll %}Poll: {% endif %}<a href="../../thread/{{ thread.id }}/">{{ thread.subject }}</a><br/><small>{% if isShowLatest %}{% sphboard_displayBreadcrumbsForCategory thread.category 1 %} - {% endif %}by {% sphboard_displayUserName thread.author %}</small></td>
          <td class="sphboard_postcount">{{ thread.postCount }}</td>
          <td class="sphboard_latestpost">{% sphboard_latestPost thread.latestPost 0 %}
        </tr>
      {% endfor %}
      <tr>
        <td colspan="4"><span style="float:left;">{{ hits }} Threads in this category yet.</span><span style="display:block;float:right;">{% sphboard_pagination pages page %}</span></td>
      </tr>
    </table>
    <br/><br/>
    {% include "sphene/sphboard/_new_thread_link.html" %}
    {% if user.is_authenticated and category.has_new_posts %}
      - <a href="../../catchup/{{ category.id }}/" title="Mark all Posts in this Category as read.">Catch Up</a>
    {% endif %}
  {% endif %}

  <br/><br/>

{% endblock %}
